<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:easy="http://easyfaces.com.br/easyfaces"
	xml:lang="en" lang="en">
	
	<ui:composition template="/WEB-INF/templates/layout_sedna_express.xhtml">
		
		
		<ui:define name="header2">
			<h:form>
				<div id="painelCotacao">
					<rich:panel style="font-size: 12px;">
						<h:outputText value="Cotação: "/><h:outputText value="#{telaCotacaoEdicao.cotacao.codigo}" styleClass="espacamento_palavras_tela_cotacao"/>
						<h:outputText value="Data: "/><easy:outputCalendar value="#{telaCotacaoEdicao.cotacao.dataCadastro}" styleClass="espacamento_palavras_tela_cotacao"/>
						<h:outputText value="Quantidade de Itens: "/><easy:outputCurrency id="valorTotalCotacao" value="#{telaCotacaoEdicao.cotacao.quantidadeItens}" styleClass="espacamento_palavras_tela_cotacao"/>
						<h:outputText value="Valor: "/><easy:outputCurrency value="#{telaCotacaoEdicao.cotacao.valorTotal}"/>
					</rich:panel>
					<h:commandButton value="Imprimir" style="margin-top: 6px;"/>
					<h:commandButton value="Salvar" style="margin-top: 6px;" action="#{telaCotacaoEdicao.salvar}"/>
					<h:commandButton value="Cancelar" style="margin-top: 6px;"/>
				</div>
			</h:form>
		</ui:define>


		<ui:define name="conteudo_center">
			<h:form>
			
				<div id="gridCotacao" class="gridProdutos">

					<rich:dataTable id="tabelaItens" value="#{telaCotacaoEdicao.itensCotacao}" var="item" rows="10" width="100%">

						<f:facet name="header">
							<h:outputText value="Itens" />
						</f:facet>

						<rich:column width="30px;" id="colunaAcoes">
							<f:facet name="header">
								<h:outputText value="Ações" />
							</f:facet>

							<a4j:commandLink ajaxSingle="true" id="deletelink" oncomplete="#{rich:component('deletePanel')}.show()">
								<h:graphicImage value="/imagens/delete.gif" style="border:0" />
								<f:setPropertyActionListener value="#{item}" target="#{telaCotacaoEdicao.itemSelecionado}" />
							</a4j:commandLink>
							
							<rich:toolTip for="deletelink" value="Apagar" />
						</rich:column>

						<rich:column id="colunaNome">
							<f:facet name="header">
								<h:outputText value="Nome" />
							</f:facet>
							<h:outputText value="#{item.nomeProduto}" id="nome" />
						</rich:column>

						<rich:column style="width: 10%" id="colunaEmpresa">
							<f:facet name="header">
								<h:outputText value="Empresa" />
							</f:facet>
							<h:outputText value="#{item.nomeEmpresa}" />
						</rich:column>

						<rich:column style="width: 10%" id="colunaQuantidade">
							<f:facet name="header">
								<h:outputText value="Quantidade" />
							</f:facet>
							<easy:inputCurrency value="#{item.quantidade}">
								<a4j:support event="onkeyup"
									reRender="painelCotacao, valorTotal" />
							</easy:inputCurrency>
						</rich:column>

						<rich:column style="width: 10%" id="colunaValorUnitario">
							<f:facet name="header">
								<h:outputText value="Valor Unitário" />
							</f:facet>
							<easy:outputCurrency value="#{item.valor}" />
						</rich:column>

						<rich:column style="width: 10%" id="valorTotal">
							<f:facet name="header">
								<h:outputText value="Total" />
							</f:facet>
							<easy:outputCurrency value="#{item.valorTotal}" />
						</rich:column>

						<rich:column style="width: 10%" id="dataContacao">
							<f:facet name="header">
								<h:outputText value="Cotado em" />
							</f:facet>
							<easy:outputCalendar value="#{item.dataUltimaPesquisaProduto}" />
						</rich:column>

						<f:facet name="footer">
							<rich:datascroller renderIfSinglePage="false" maxPages="10" />
						</f:facet>

					</rich:dataTable>

				</div>
				
			</h:form>

			<!-- PAINEL MODAL DE EXCLUSÃO -->
			<rich:modalPanel id="deletePanel" autosized="true" width="200">
				<f:facet name="header">
					<h:outputText value="Remove este item?" style="padding-right:15px;" />
				</f:facet>
				<f:facet name="controls">
					<h:panelGroup>
						<h:graphicImage value="/imagens/close.png" styleClass="hidelink"
							id="hidelink2" />
						<rich:componentControl for="deletePanel" attachTo="hidelink2"
							operation="hide" event="onclick" />
					</h:panelGroup>
				</f:facet>
				<h:form>
					<table width="100%">
						<tbody>
							<tr>
								<td align="center" width="50%">
									<a4j:commandButton value="Sim" ajaxSingle="true"
										action="#{telaCotacaoEdicao.removerItem}"
										oncomplete="#{rich:component('deletePanel')}.hide();"
										reRender="tabelaItens" />
								</td>
								<td align="center" width="50%">
									<a4j:commandButton value="Cancelar" onclick="#{rich:component('deletePanel')}.hide();return false;" />
								</td>
							</tr>
						</tbody>
					</table>
				</h:form>
			</rich:modalPanel>

		</ui:define>

	</ui:composition>
</html>
